<?php
class CV_Datastore_Metadata_Relational_Provider_Mysql_Table{
	private $_metadata;
	private $_database;
	function __construct( $metadata, $database ){
		$this->_metadata = $metadata;
		$this->_database = $database;
	}
	function set_columns( $columns ){
		$this->columns = new CV_Collection_Object( $columns );
	}
	function get_columns(){
		return $this->columns;
	}
	function get_name(){
		return $this->_metadata['TABLE_NAME'];			
	}
	function get_database(){
		return $this->_databsse;			
	}
	function __get( $name ){
		switch( $name ){
			case 'sql_identifier':
				return strtolower( $this->_database->get_sql_name().'.'.$this->get_name() );
			default:
				return $this->$name;
		}		
	}
	function get_primary_key(){
		$return = array();
		foreach( $this->columns as $column ){
			if( $column->is_primary_key() ){
				$return[] = $column->name;
			} 
		}
		return $return;
	}
}